﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Mvc;
using System.Text;
using MensUnoShop.Models;
using MensUnoShop.Filters;
using MensUnoShop.Models.ViewModels;
using SenerPro;

namespace MensUnoShop.Controllers
{
    public class TestController : Controller
    {
        //
        // GET: /Test/
        private List<Tag> _toptaglist;

        public ActionResult Index()
        {
            _toptaglist = TagFactory.GetTopTagList();
            IndexViewModel iv = new IndexViewModel { TOPLIST = _toptaglist };
            PayFactory pf = new PayFactory();

            string chkHash = pf.GetMD5Hash("merchantnumber=456059&ordernumber=100000480&serialnumber=2745261&writeoffnumber=010826FU225986&timepaid=20110826124036&paymenttype=IBON&amount=570&tel=0976032592" + "25riictp");
            ViewData["chkHash"] = chkHash;
            return View(iv);
        }

        public ActionResult PayCreditcard(string id)
        {            
            PayFactory pf = new PayFactory();
            string s = string.Empty;
            string dostring = pf.DoCreditcardTrade("AA" + DateTime.Now.ToString("yyyyMMddHHmmss"), 50, ref s);
            Response.Clear();
            Response.Write(dostring);
            return View();
        }

        public ActionResult PayALIPAY(string id)
        {
            PayFactory pf = new PayFactory();
            string s = string.Empty;
            string dostring = pf.DoCSTrade("AA" + DateTime.Now.ToString("yyyyMMddHHmmss"), 50, "購物訂單ALIPAY", DateTime.Now.AddDays(5), "阿嘉", "123456789", PayType.ALIPAY, ref s);
            Response.Clear();
            Response.Write(dostring);
            return View();
        }

        public ActionResult PayMMK(string id)
        {
            PayFactory pf = new PayFactory();
            string s = string.Empty;
            string dostring = pf.DoCSTrade("AA" + DateTime.Now.ToString("yyyyMMddHHmmss"), 50, "購物訂單MMK", DateTime.Now.AddDays(5), "阿嘉", "123456789", PayType.MMK, ref s);
            Response.Clear();
            Response.Write(dostring);
            return View();
        }

        public ActionResult PayWEBATM(string id)
        {
            PayFactory pf = new PayFactory();
            string s = string.Empty;
            string dostring = pf.DoCSTrade("AA" + DateTime.Now.ToString("yyyyMMddHHmmss"), 50, "購物訂單WebATM", DateTime.Now.AddDays(5), "阿嘉", "123456789", PayType.WebATM, ref s);
            Response.Clear();
            Response.Write(dostring);
            return View();
        }

        public ActionResult PayATM(string id)
        {
            PayFactory pf = new PayFactory();
            string s = string.Empty;
            string dostring = pf.DoCSTrade("AA" + DateTime.Now.ToString("yyyyMMddHHmmss"), 50, "購物訂單ATM", DateTime.Now.AddDays(5), "阿嘉", "123456789", PayType.ATM, ref s);
            Response.Clear();
            Response.Write(dostring);
            return View();
        }

        public ActionResult PayCS(string id)
        {
            PayFactory pf = new PayFactory();
            string s = string.Empty;
            string dostring = pf.DoCSTrade("AA" + DateTime.Now.ToString("yyyyMMddHHmmss"), 50, "購物訂單CS", DateTime.Now.AddDays(5), "阿嘉", "123456789", PayType.CS, ref s);
            Response.Clear();
            Response.Write(dostring);
            return View();
        }

        public ActionResult PayCSQuery(int id)
        {
            PayFactory pf = new PayFactory();
            string dostring = pf.DoCSTradeQuery(id);
            Response.Clear();
            Response.Write(dostring);
            return View();
        }

        public ActionResult Test(string id)
        {
            PayFactory pf = new PayFactory();
            PayInfoCreditcard pic = new PayInfoCreditcard();
            pic = pf.GetPayInfoCreditcard(100000040);

            Response.Clear();
            Response.Write("<script>alert('" + pic.APPROVALCODE + "')</script>");

            return View();
        }


    }
}
